package com.tanhua.server.exception;

import com.tanhua.model.vo.ErrorResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler(Exception.class)
    public ResponseEntity handlerException(Exception e){
        e.printStackTrace();

        ErrorResult vo = ErrorResult.error();

        return ResponseEntity.status(500).body(vo);

    }

    @ExceptionHandler(BusinessException.class)
    public ResponseEntity handlerBusinessException(BusinessException e){
        e.printStackTrace();

        ErrorResult vo = e.getVo();

        return ResponseEntity.status(500).body(vo);

    }


}
